﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using nERP.Model.Po;
using nERP.Model;

using nERP.Model.Po;
using nERP.Model.Bas;
using nERP.Model.Wms;


namespace nERP.ViewModel.Po.BuyReturnDetailVMs
{
    public partial class BuyReturnDetailBuyReturnDetailListVM : BasePagedListVM<BuyReturnDetail, BuyReturnDetailDetailSearcher>
    {
        
        protected override List<GridAction> InitGridAction()
        {
            return new List<GridAction>
            {
                this.MakeStandardAction("BuyReturnDetail", GridActionStandardTypesEnum.AddRow, "新建","", dialogWidth: 800),
                this.MakeStandardAction("BuyReturnDetail", GridActionStandardTypesEnum.RemoveRow, "删除","", dialogWidth: 800),
            };
        }
 
        protected override IEnumerable<IGridColumn<BuyReturnDetail>> InitGridHeader()
        {
            return new List<GridColumn<BuyReturnDetail>>{
                
                this.MakeGridHeader(x => x.ID).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.ID"].Value),
                this.MakeGridHeader(x => x.CreateTime).SetEditType(EditTypeEnum.Datetime).SetTitle(@Localizer["_Admin.CreateTime"].Value),
                this.MakeGridHeader(x => x.UpdateTime).SetEditType(EditTypeEnum.Datetime).SetTitle(@Localizer["_Admin.UpdateTime"].Value),
                this.MakeGridHeader(x => x.CreateBy).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["_Admin.CreateBy"].Value),
                this.MakeGridHeader(x => x.UpdateBy).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["_Admin.UpdateBy"].Value),
                this.MakeGridHeader(x => x.TenantCode).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["_Admin.Tenant"].Value),
                this.MakeGridHeader(x => x.Seq).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.序号"].Value),
                this.MakeGridHeader(x => x.BuyReturnDetailCode).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.采购退货明细单号"].Value),
                this.MakeGridHeader(x => x.BuyInWarehouseDetailId).SetEditType(EditTypeEnum.ComboBox,DC.Set<BuyInWarehouseDetail>().GetSelectListItems(Wtm, x => x.BuyInWarehouseDetailCode, x => x.BuyInWarehouseDetailCode,SortByName:true)).SetTitle(@Localizer["Page.采购入库明细"].Value),
                this.MakeGridHeader(x => x.BuyId).SetEditType(EditTypeEnum.ComboBox,DC.Set<Buy>().GetSelectListItems(Wtm, x => x.BuyCode, x => x.BuyCode,SortByName:true)).SetTitle(@Localizer["Page.采购"].Value),
                this.MakeGridHeader(x => x.BuyDatailId).SetEditType(EditTypeEnum.ComboBox,DC.Set<BuyDetail>().GetSelectListItems(Wtm, x => x.BuyDetailCode, x => x.BuyDetailCode,SortByName:true)).SetTitle(@Localizer["Page.采购明细"].Value),
                this.MakeGridHeader(x => x.GoodsId).SetEditType(EditTypeEnum.ComboBox,DC.Set<Goods>().GetSelectListItems(Wtm, x => x.GoodsName, x => x.GoodsCode,SortByName:true)).SetTitle(@Localizer["Page.商品"].Value),
                this.MakeGridHeader(x => x.GoodsName).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.商品名称"].Value),
                this.MakeGridHeader(x => x.GoodsSpec).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.商品规格"].Value),
                this.MakeGridHeader(x => x.GoodsUnit).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.商品单位"].Value),
                this.MakeGridHeader(x => x.ReturnNumber).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.退货数量"].Value),
                this.MakeGridHeader(x => x.UnitPrice).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.退货单价"].Value),
                this.MakeGridHeader(x => x.DiscountPrice).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.折扣价格"].Value),
                this.MakeGridHeader(x => x.TotalPrice).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.退货金额"].Value),
                this.MakeGridHeader(x => x.TaxRate).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.税率"].Value),
                this.MakeGridHeader(x => x.TaxUnitPrice).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.含税单价"].Value),
                this.MakeGridHeader(x => x.TaxPrice).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.税额"].Value),
                this.MakeGridHeader(x => x.TotalTaxPrice).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.含税金额"].Value),
                this.MakeGridHeader(x => x.Remark).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["_Admin.Remark"].Value),
                this.MakeGridHeader(x => x.Status).SetEditType(EditTypeEnum.ComboBox,typeof(dStatusTypeEnum).ToListItems(null,true)).SetTitle(@Localizer["Page.状态"].Value),

                this.MakeGridHeaderAction(width: 200)
            };
        }

        
        public override IOrderedQueryable<BuyReturnDetail> GetSearchQuery()
        {
                
            var id = (string)Searcher.BuyReturnId.ConvertValue(typeof(string));
            if (id == null)
                return new List<BuyReturnDetail>().AsQueryable().OrderBy(x => x.ID);
            var query = DC.Set<BuyReturnDetail>()
                .Where(x => id == x.BuyReturnId)

                .OrderBy(x => x.ID);
            return query;
        }

    }

    public partial class BuyReturnDetailDetailSearcher : BaseSearcher
    {
        
        [Display(Name = "_Model._BuyReturnDetail._BuyReturn")]
        public string BuyReturnId { get; set; }
    }

}

